clear all 
use "data\out\estsample.dta", clear
g byte PeakxEvent = Peak*EventDay
g byte ShoulderxEvent = shoulder*EventDay

/*
reghdfe lnforbruk TPE TNPE TPnextdays TNPnextdays  ///
  Peak c.temp##c.temp##c.temp temp_*, absorb(maalepktnr dato) vce(cluster maalepktnr)
est store RF1
estadd ysumm  

reghdfe lnforbruk TPE TNPE TPnextdays TNPnextdays Peak ///
  TPEelcar TNPEelcar TPnextdayselcar TNPnextdayselcar Peakelcar  ///
  c.temp##c.temp##c.temp temp_*, absorb(maalepktnr dato) vce(cluster maalepktnr)
est store RF2
estadd ysumm  
*/ 
ivreghdfe lnforbruk Peak PeakxEvent ///
  (Effektpris EffektprisNonPeak Effektprisnext EffektprisNonPeaknext =  TPE TNPE TPnextdays TNPnextdays), absorb(maalepktnr dato) cluster(maalepktnr)
est store IV1
estadd ysumm  

ivreghdfe lnforbruk c.temp##c.temp##c.temp temp_* Peak PeakxEvent ///
  (Effektpris EffektprisNonPeak Effektprisnext EffektprisNonPeaknext =  TPE TNPE TPnextdays TNPnextdays), absorb(maalepktnr dato) cluster(maalepktnr)
est store IV2
estadd ysumm  

ivreghdfe lnforbruk c.temp##c.temp##c.temp temp_* Peak PeakxEvent Peakelcar ///
  (Effektpris EffektprisNonPeak Effektprisnext EffektprisNonPeaknext Effektpriselcar EffektprisNonPeakelcar Effektprisnextelcar EffektprisNonPeaknextelcar =  TPE TNPE TPnextdays TNPnextdays TPEelcar TNPEelcar TPnextdayselcar TNPnextdayselcar ), absorb(maalepktnr dato) cluster(maalepktnr)
est store IV3
estadd ysumm  

ivreghdfe lnforbruk c.temp##c.temp##c.temp temp_* Peak PeakxEvent ShoulderxEvent shoulder ///
  (Effektpris EffektprisNonPeak Effektprisnext EffektprisNonPeaknext Effektprisshoulder =  TPE TNPE TPnextdays TNPnextdays TsE), absorb(maalepktnr dato) cluster(maalepktnr)
est store IV4
estadd ysumm  

ivreghdfe lnforbruk c.temp##c.temp##c.temp temp_* Peak PeakxEvent ShoulderxEvent Peakelcar shoulder shoulderelcar ///
  (Effektpris EffektprisNonPeak Effektprisnext EffektprisNonPeaknext Effektpriselcar EffektprisNonPeakelcar Effektprisnextelcar EffektprisNonPeaknextelcar Effektprisshoulder Effektprisshoulderelcar =  TPE TNPE TPnextdays TNPnextdays TPEelcar TNPEelcar TPnextdayselcar TNPnextdayselcar TsE TsEelcar), absorb(maalepktnr dato) cluster(maalepktnr)
est store IV5
estadd ysumm  


estout IV1 IV2 IV3 IV4 IV5 using "output\table_2_results_IV.txt", replace type ///
  cells(b( fmt(3)) se(par fmt(3)) _star) indicate(temp) mlabels(1 2 3 4 5 6 ) collabels(none) legend ///
  order(Effektpris EffektprisNonPeak Effektprisnext EffektprisNonPeaknext Peak PeakxEvent ShoulderxEvent Effektpriselcar EffektprisNonPeakelcar Effektprisnextelcar EffektprisNonPeaknextelcar Peakelcar Effektprisshoulder shoulder Effektprisshoulderelcar shoulderelcar) ///
  varlabels(TPE TP TNPE TNP) starlevels(* 0.10 ** 0.05 *** 0.01) varwidth(26) ///
  stats(ymean r2 N, fmt(3 3 0 0)) style(tex)

  